package com.centersoft.flowable.core.model;

import com.alibaba.fastjson.JSONObject;
import com.centersoft.flowable.core.annotation.WorkFlowAuditType;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Map;

/**
 * 发起审核的请求参数
 * @author wangzhiqiang
 * @since 2025/3/12 11:03
 */
@Data
@Accessors(chain = true)
public class ReviewRequest {
    /**
     * 模块编号
     */
    private String menuCode;
    /**
     * 审批类型
     */
    private WorkFlowAuditType workFlowAuditType;
    /**
     * 流程名称
     */
    private String workFLowName;

    /**
     * 当前组织编号
     */
    private String orgCode;
    /**
     * 流程定义的key
     */
    private String procDefKey;
    /**
     * 流程实例id
     */
    private String procInsId;

    /**
     * 表单的数据
     */
    private JSONObject formData;
    /**
     * 单据编码
     */
    private String billcode;
    /**
     * 单据名称
     */
    private String orderName;
    /**
     * TODO 未知的类型，后续研究
     */
    private String assigneeTypes;
    /**
     * 流程发起人/当前审批人
     */
    private String applyUserId;
    /**
     * 流程发起人/当前审批人名称
     */
    private String applyUserName;


    public static ReviewRequest fromStartRequest(StartProcessRequest startProcessRequest) {
        ReviewRequest reviewRequest = new ReviewRequest();
        reviewRequest.setMenuCode(startProcessRequest.getMenuCode());
        reviewRequest.setOrgCode(startProcessRequest.getOrgCode());
        reviewRequest.setFormData(startProcessRequest.getFormData());
        reviewRequest.setBillcode(startProcessRequest.getBillcode());
        reviewRequest.setOrderName(startProcessRequest.getOrderName());
        reviewRequest.setAssigneeTypes(startProcessRequest.getAssigneeTypes());
        reviewRequest.setApplyUserId(startProcessRequest.getApplyUserId());
        reviewRequest.setApplyUserName(startProcessRequest.getApplyUserName());
        return reviewRequest;
    }

    public Map<String, Object> toMap() {
        return (JSONObject) JSONObject.toJSON(this);
    }
}
